package cn.bdqn.service.sys.impl;

import cn.bdqn.dao.sys.SysSwiperDao;
import cn.bdqn.entity.SwiperImage;
import cn.bdqn.service.sys.SysSwiperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;

/**
 * @ProjectName: ycbdqn
 * @Package: cn.bdqn.service.sys.impl
 * @Author: huat
 * @Date: 2020/3/10 14:54
 * @Version: 1.0
 */
@Service
public class SysSwiperServiceImpl implements SysSwiperService {
    @Autowired
    SysSwiperDao sysSwiperDao;
    /**
     * 查询轮播图
     * @param page 起始位置
     * @param limit 页面大小
     * @param swiperName    轮播图名称
     * @return
     */
    @Override
    public Map<String, Object> getAllSwiper(int page, int limit, String swiperName) {
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("count",sysSwiperDao.countSwiper(swiperName));
        map.put("data",sysSwiperDao.getAllSwiper((page-1)*limit, limit, swiperName));
        map.put("code",0);
        return map;
    }
    /**
     * 根据id删除轮播图
     * @param swiperId 轮播图id
     * @return
     */
    @Override
    @Transactional
    public boolean deleteSwiper(int swiperId) {
        return sysSwiperDao.deleteSwiper(swiperId) > 0?true:false;
    }

    /**
     * 根据id查询轮播图
     * @param swiperId
     * @return
     */
    @Override
    public SwiperImage getSwiperImageById(int swiperId) {
        return sysSwiperDao.getSwiperImageById(swiperId);
    }

    /**
     * 根据id修改轮播图
     * @param swiperImage
     * @return
     */
    @Override
    public String updateSwiperById(SwiperImage swiperImage) {
        return sysSwiperDao.updateSwiperById(swiperImage)+"";
    }
    /**
     * 添加轮播图
     * @param swiperImage
     * @return
     */
    @Override
    public String addSwiper(SwiperImage swiperImage) {
        return sysSwiperDao.addSwiper(swiperImage)+"";
    }
}
